//
//  OEMemberCenterViewController.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/5.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEMemberCenterViewController.h"
#import "OENormalPayViewController.h"
@interface OEMemberCenterViewController ()
@property(nonatomic, strong) STLabel                     *moneyLable;/**<  */
@property(nonatomic, strong) NSString                     *money;/**< <##> */
@end

@implementation OEMemberCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = OESTRING(@"MEMBER CENTER");
    [self configSubView];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [OEUserDataController sendFetcBeVipMoneyRequest:^(NSString * _Nonnull money) {
        self.moneyLable.text = [NSString stringWithFormat:@"￥%@/Month",money];
        self.money = money;
    }];

}
#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, UIScreenWidth - 20, 205)];
    imageView.image = [UIImage imageNamed:@"702×386VIP"];
    imageView.layer.cornerRadius = 4;
    imageView.clipsToBounds = YES;
    [header addSubview:imageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, imageView.width, 40)
                                                     text:@""
                                                textColor:UIColor.whiteColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    titleLable.right = imageView.width - 10;
    titleLable.bottom = imageView.bottom - 30;
    [imageView addSubview:titleLable];
    self.moneyLable = titleLable;
    
    
    STLabel * aletitleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, imageView.bottom, imageView.width, 40)
                                                     text:OESTRING(@"MEMBERSHI RIGHTS")
                                                textColor:UIColor.blackColor
                                                     font:16
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];

    [header addSubview:aletitleLable];
    
    CGFloat top = aletitleLable.bottom+10;
    ({
        UIView * view = [self viewFormImageName:@"100×100合作" title:OESTRING(@"Arbitrary extration") subTitle:OESTRING(@"pick up our shared pruductes from any partner company")];
        view.top = top;
        [header addSubview:view];
        top = view.bottom;
    });
    ({
        UIView * view = [self viewFormImageName:@"100×100资产" title:OESTRING(@"Restitution") subTitle:OESTRING(@"Within 6 days,no fee can be returned to any cooperative business")];
        view.top = top;
        [header addSubview:view];
        top = view.bottom;
    });
    ({
        UIView * view = [self viewFormImageName:@"100×100收费" title:OESTRING(@"No chare for damage") subTitle:OESTRING(@"No chare for damage,lost charge 10")];
        view.top = top;
        [header addSubview:view];
        top = view.bottom;
    });
    header.height = top + 20;
    self.tableView.tableHeaderView = header;

    __weak typeof(self) weakSelf =  self;
    STButton * payButton = [[STButton alloc] initWithFrame:CGRectMake(40, 0, UIScreenWidth - 80, 44)
                                                     title:OESTRING(@"OPEN UP IMMEDIATELY")
                                                titleColor:UIColor.whiteColor
                                                 titleFont:15
                                              cornerRadius:22
                                           backgroundColor:OE_LIMITE_COLOR
                                           backgroundImage:nil
                                                     image:nil];
    payButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    payButton.top = TMUtils.tabBarTop - 40 ;
    [payButton makeImageRight];
    [self.view addSubview:payButton];
    [payButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedPayButton];
    }];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.contentInset = UIEdgeInsetsZero;
    self.tableView.frame = CGRectMake(0, TMUtils.navgationBarBootom, UIScreenWidth, payButton.top - TMUtils.navgationBarBootom);
}
- (UIView*)viewFormImageName:(NSString*)imageName title:(NSString*)title subTitle:(NSString*)subTitle{
    UIView  *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 80)];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 60)];
    imageView.image = [UIImage imageNamed:imageName];
    [view addSubview:imageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(imageView.right + 10, imageView.top, view.width - imageView.right - 20, 20)
                                                     text:title
                                                textColor:FirstTextColor
                                                     font:16
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [view addSubview:titleLable];
    
    STLabel * stitleLable = [[STLabel alloc] initWithFrame:CGRectMake(imageView.right + 10, titleLable.bottom, view.width - imageView.right - 20, 40)
                                                     text:subTitle
                                                textColor:SecendTextColor
                                                     font:13
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [NSString lableAutoAdjustheightWithLabel:stitleLable];
    stitleLable.bottom = imageView.bottom;
    [view addSubview:stitleLable];
    return  view;
}
- (void)onSelctedPayButton{
    OENormalPayViewController * vc= OENormalPayViewController.new;
    vc.money = self.money;
    [self.navigationController pushViewController:vc animated:YES];
}
@end
